<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\business\EhrHelper;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $searchModel common\models\kingdee\OrgAdminSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('kingdee', 'Org Admins');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="org-admin-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Org Admin'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?php
    try {
        $gv = GridView::widget([
            'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
            'pager' => [
//            'class'          => GoPager::className(),
                'nextPageLabel'  => Yii::t('app', 'Next Page'),
                'prevPageLabel'  => Yii::t('app', 'Previous Page'),
                'firstPageLabel' => Yii::t('app', 'First Page'),
                'lastPageLabel'  => Yii::t('app', 'Last Page'),
                'options' => [
                    'class' => 'pagination pagination-sm m-t-none m-b-none',
                ],
            ],
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'columns' => [
                [
                    'class' => 'yii\grid\SerialColumn',
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
                ],
//            'FID',
//            'FNAME_L1',
//            'FNAME_L2',
//            'FNAME_L3',
//            'FNUMBER',
                // 'FDESCRIPTION_L1',
                // 'FDESCRIPTION_L2',
                // 'FDESCRIPTION_L3',
                // 'FSIMPLENAME',
                // 'FISGROUPING',
                // 'FEFFECTDATE',
                // 'FINVALIDDATE',
                // 'FISFREEZE',
                // 'FISCOMPANYORGUNIT',
                // 'FISADMINORGUNIT',
                // 'FISSALEORGUNIT',
                // 'FISPURCHASEORGUNIT',
                // 'FISSTORAGEORGUNIT',
                // 'FISPROFITORGUNIT',
                // 'FISCOSTORGUNIT',
                // 'FISCU',
                // 'FISUNION',
                // 'FISHRORGUNIT',
                // 'FCREATORID',
                // 'FCREATETIME',
//             'FLASTUPDATEUSERID',
                // 'FLASTUPDATETIME',
                // 'FCONTROLUNITID',
                // 'FISLEAF',
                // 'FLEVEL',
                // 'FLONGNUMBER',
                // 'FPARENTID',
                // 'FISENTITY',
                // 'FISVIRTUAL',
                // 'FPHONENUMBER',
                // 'FLAYERID',
//             'FRESPONPOSITIONID',
                // 'FADDRESSID',
//             'FPRINCIPALID', 负责人
                // 'FLAYERTYPEID',
//             'FBASEDUTY_L1',
//             'FBASEDUTY_L2',


//             'FBASEDUTY_L3',
                // 'FINDEX',
                // 'FJOBSYSTEMID',
                // 'FADMINADDRESS_L1',
                // 'FADMINADDRESS_L2',
                // 'FADMINADDRESS_L3',
                // 'FZIPCODE',
                // 'FFAX',
                // 'FISSEALUP',
                // 'FISSTART',
                // 'FISOUSEALUP',
                // 'FDISPLAYNAME_L1',
                // 'FDISPLAYNAME_L2',
                // 'FDISPLAYNAME_L3',
                // 'FPROPERTYSEALUPDATE',
                // 'FVERSIONNUMBER',
                // 'FCODE',
                // 'FISTRANSPORTORGUNIT',
                // 'FISQUALITYORGUNIT',
                // 'FSORTCODE',
                // 'FINDUSTRYID',
                // 'FECONOMICTYPE',
                // 'FREGISTEREDCAPITAL',
                // 'FREGISTEREDCODE',
                // 'FSETUPDATE',
                // 'FENDUPDATE',
                // 'FTAXNUMBER',
                // 'FISCHURCHYARD',
                // 'FJURIDICALPERSONID',
                // 'FISJURIDICALCOMPANY',
                // 'FISINDEPENDENCE',
                // 'FTERRITORY_L1',
                // 'FTERRITORY_L2',
                // 'FTERRITORY_L3',
                // 'FORGCODE',
                // 'FAREAID',
                // 'FORGPROPERTYID',
                // 'FREGISTTYPEID',
                 'FEFFDT',
                 'FLEFFDT',
                // 'FHISTORYRELATEID',
                // 'FDELEGATEHRID',
                // 'FORGFUNCTIONID',
                // 'FCOMPANYID',
                // 'FDEPARTMENTID',
                // 'FOFFICEID',
                // 'FLEVELFOURGROUPID',
                // 'FLEVELFIVEGROUPID',
                // 'FLEVELFIVEGROUP',
                // 'FLEVELSIXGROUPID',
                // 'FRESERVEFIELDFIRST',
                // 'FRESERVEFIELDSECOND',
                // 'FRESERVEITEMFIRST',
                // 'FRESERVEITEMSECOND',
                // 'FISSTARTSHR',
                // 'FORGTYPESTR',
                [
                    'label' => Yii::t('app', 'MDM Code'),
                    'attribute' => 'FBASEDUTY_L2',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                ],
                [
                    'label' => Yii::t('app', 'Name'),
                    'attribute' => 'FNAME_L2',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                ],
                [
                    'attribute' => 'FORGPROPERTYID',
                    'label' => Yii::t('app', 'Plate'),
                    'value' => function ($model) {
                        return EhrHelper::getOrgPropertyById($model['FORGPROPERTYID']);
                    },
                    'filter' => ArrayHelper::map(\common\models\kingdee\OrgProperty::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'label' => Yii::t('app', 'Parent Org'),
                    'attribute' => 'FPARENTID',
                    'value'     => function ($model) {
                        return Html::a(EhrHelper::getOrgAdminById($model['FPARENTID']), [
                            '/kingdee/org-admin/view',
                            'id' => $model['FPARENTID'],
                        ],
                            ['target' => '_blank']);
                    },
                    'format'    => 'raw',
                    'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FDISPLAYNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'label' => Yii::t('app', 'Number'),
                    'attribute' => 'FNUMBER',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                ],
                [
                    'attribute' => 'FLAYERTYPEID',
                    'label' => Yii::t('app', 'Org Layer'),
                    'value' => function ($model) {
                        return EhrHelper::getOrgLayerTypeById($model['FLAYERTYPEID']);
                    },
                    'filter' => ArrayHelper::map(\common\models\kingdee\OrgLayerType::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'label'     => Yii::t('app', 'Industry'),
                    'attribute' => 'FINDUSTRYID',
                    'value'     => function ($model) {
                        return Html::a(EhrHelper::getIndustryById($model['FINDUSTRYID']), [
                            '/kingdee/industry/view',
                            'id' => $model['FINDUSTRYID'],
                        ],
                            ['target' => '_blank']);
                    },
                    'format'    => 'raw',
                    'filter' => ArrayHelper::map(\common\models\kingdee\Industry::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'label'     => Yii::t('app', 'Response Position'),
                    'attribute' => 'FRESPONPOSITIONID',
                    'value'     => function ($model) {
                        return Html::a(EhrHelper::getOrgPositionById($model['FRESPONPOSITIONID']), [
                            '/kingdee/org-position/view',
                            'id' => $model['FRESPONPOSITIONID'],
                        ],
                            ['target' => '_blank']);
                    },
                    'format'    => 'raw',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'attribute' => 'FCOMPANYID',
                    'label' => Yii::t('app', 'Company'),
                    'value' => function ($model) {
                        return EhrHelper::getOrgAdminById($model['FCOMPANYID']);
                    },
//                'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'attribute' => 'FDEPARTMENTID',
                    'label' => Yii::t('app', 'Department'),
                    'value' => function ($model) {
                        return EhrHelper::getOrgAdminById($model['FDEPARTMENTID']);
                    },
//                'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'attribute' => 'FCONTROLUNITID',
                    'label' => Yii::t('app', 'Control Unit'),
                    'value' => function ($model) {
                        return EhrHelper::getControlUnitStrById($model['FCONTROLUNITID']);
                    },
                    'filter' => ArrayHelper::map(\common\models\kingdee\CtrlUnit::find()->all(), 'FID', 'FNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                ['class' => 'yii\grid\ActionColumn'],
            ],
        ]);
    } catch (Exception $e) {
    }
    ?>
    <?= $gv ?>
</div>
